//
//  BtnTableViewCell.m
//  YaoHeAPP
//
//  Created by mac on 15/12/19.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "BtnTableViewCell.h"
#import "Masonry.h"

#import "UIView+HY.h"

#define lFont [UIFont systemFontOfSize:15]
#define tColor [UIColor darkGrayColor]
@implementation BtnTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier ];
    if (self) {
        
        //是否是推荐的（是推荐的要展示一张图片）
        _tui_jian=[UIImageView new];
        [self addSubview:_tui_jian];
        [_tui_jian mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(0);make.left.offset(0);
            make.height.offset(36);make.width.offset(36);
        }];
        
        //发布报价的用户头像
        _headImage=[UIImageView new];
        //_headImage.backgroundColor=[UIColor grayColor];
        _headImage.layer.masksToBounds=YES;
        _headImage.layer.cornerRadius=24;
        [self addSubview:_headImage];
        [_headImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.mas_centerY).offset(-2);
            make.left.offset(25);  make.width.offset(48);  make.height.offset(48);
        }];
        
        
        _start=[UILabel new];
        _start.textColor=[UIColor orangeColor];
        [self addSubview:_start];
        [_start mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_headImage.mas_bottom).offset(4);
            make.height.offset(18);
            make.centerX.equalTo(_headImage.mas_centerX).offset(0);
            make.width.offset(74);
        }];
       
        
        //添加到黑名单按钮
        _btnBN=[UIButton new];
        _btnBN.titleLabel.font=lFont;
        [_btnBN setTitleColor:[UIColor colorWithRed:28.f/255.f green:52.f/255.f blue:137.f/255.f alpha:1] forState:UIControlStateNormal];
        [self addSubview:_btnBN];
        [_btnBN mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_headImage.mas_centerX).offset(0);
            make.top.equalTo(_start.mas_bottom).offset(5);
            make.height.offset(20);
            make.width.offset(80);
        }];
        
        //竖条图片
        _bgImage=[UIImageView new];
        _bgImage.backgroundColor=[UIColor grayColor];
        [self addSubview:_bgImage];
//        [_bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(15);  make.left.equalTo(_btnBN.mas_right).offset(2);
//            make.width.offset(1); make.bottom.offset(-15);
//        }];
        
//        _bgImage.frame=CGRectMake(_btnBN.right+2, 15, 1, self.bottom-15);
        
        
        //报价标签
        _bao_jiaL=[UILabel new];
        _bao_jiaL.text=@"报   价:";
        _bao_jiaL.font=lFont;
        //_baojiaMesage.textColor=tColor;
        [self addSubview:_bao_jiaL];
//        [_bao_jiaL mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(15); make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(20); make.width.offset(50);
//        }];
        
         _bao_jiaL.frame=CGRectMake(110, 15, 50, 20);
        
        //报价信息
        _baojiaMesage=[UILabel new];
        _baojiaMesage.font=lFont;
        _baojiaMesage.textColor=[UIColor orangeColor];
        [self addSubview:_baojiaMesage];
//        [_baojiaMesage mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(15);  make.left.equalTo(_bao_jiaL.mas_right).offset(1);
//            make.height.offset(20);  make.right.offset(-5);
//        }];
        
         _baojiaMesage.frame=CGRectMake(_bao_jiaL.right+2, 15, self.right-5, 20);
        
        //交易员标签
        _jiao_yi=[UILabel new];
        _jiao_yi.text=@"交易员:";
        _jiao_yi.font=lFont;
        [self addSubview:_jiao_yi];
//        [_jiao_yi mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(50);  make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(20); make.width.offset(50);
//        }];
        
         _jiao_yi.frame=CGRectMake(110, _bao_jiaL.bottom+5, 50, 20);
        
        //交易人名
        _name=[UILabel new];
        _name.font=lFont;
        [self addSubview:_name];
//        [_name mas_remakeConstraints:^(MASConstraintMaker *make){
//            make.top.offset(50); make.left.equalTo(_jiao_yi.mas_right).offset(1);
//            make.height.offset(20);   make.width.offset(60);
//        }];
        
        _name.frame=CGRectMake(_jiao_yi.right+2, _bao_jiaL.bottom+5, 50, 20);
        
        //电话号码
        _phoneNum=[UIButton new];
        _phoneNum.titleLabel.font=lFont;
        //_phoneNum.backgroundColor=[UIColor yellowColor];
        [_phoneNum setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        [self addSubview:_phoneNum];
//        [_phoneNum mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(50); make.left.equalTo(_name.mas_right).offset(1);
//            make.height.offset(20); make.width.offset(100);
//        }];
        
         _phoneNum.frame=CGRectMake(_name.right+2, _bao_jiaL.bottom+5, 110, 20);
        
        
        //备注标签
        _remarkL=[UILabel new];
        _remarkL.text=@"备   注:";
        _remarkL.font=lFont;
        [self addSubview:_remarkL];
//        [_remarkL mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(85);  make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(16); make.width.offset(50);
//        }];
        
         _remarkL.frame=CGRectMake(110, _jiao_yi.bottom+5, 50, 20);
        
        //备注信息内容显示
        _textMsg=[[UILabel alloc]init];
        _textMsg.numberOfLines=0;
        _textMsg.font=lFont;
        _textMsg.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_textMsg];
        
//        [_textMsg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_remarkL.mas_right).offset(2);
//            make.right.offset(-5);
//            make.top.offset(85);
////            make.height.offset([_textMsg.text  boundingRectWithSize: CGSizeMake(_textMsg.frame.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:_textMsg.font ,NSFontAttributeName, nil] context:nil].size.height);
//        }];
        
        //第一个view
        _oView=[UIView new];
        [self addSubview:_oView];
//        [_oView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(40);
//            make.bottom.offset(-5);
//            make.right.offset(0);
//        }];
        
        UIImageView*lockImage=[[UIImageView alloc]init];
        lockImage.image=[UIImage imageNamed:@"ic_lock"];
        [_oView addSubview:lockImage];
        [lockImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(22);  make.top.offset(11);
            make.bottom.offset(-11);  make.width.offset(16);
        }];
        UILabel*lab=[UILabel new];
        lab.text=@"锁货";
        lab.font=lFont;
        [_oView addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(41);  make.top.offset(10);
            make.bottom.offset(-10);  make.width.offset(30);
        }];
         //锁货按钮
        _suoHuo1=[UIButton new];
        _suoHuo1.titleLabel.font=lFont;
        //_suoHuo1.backgroundColor=[UIColor clearColor];
        [_oView addSubview:_suoHuo1];
        [_suoHuo1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(2);  make.top.offset(7);
            make.bottom.offset(-7);  make.width.offset(88);
        }];

        //直接下单按钮
        _xiaDan1=[UIButton new];
        _xiaDan1.titleLabel.font=lFont;
        [_xiaDan1 setTitle:@"直接下单" forState:UIControlStateNormal];
        [_xiaDan1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_oView addSubview:_xiaDan1];
        [_xiaDan1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_suoHuo1.mas_right).offset(20);
            make.top.offset(7);
            make.bottom.offset(-7);
            make.width.offset(88);
        }];
        
        //第二个view
        _tView =[UIView new];
        [self addSubview:_tView];
//        [_tView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(40);
//            make.bottom.offset(-5);
//            make.right.offset(0);
//        }];
        //确认订单按钮（点击弹出订单结算页）
        _sure2=[UIButton new];
        _sure2.titleLabel.font=lFont;
        [_sure2 setTitle:@"确认订单" forState:UIControlStateNormal];
        [_sure2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _sure2.backgroundColor=[UIColor colorWithRed:54.f/255.f green:177.f/255.f blue:248.f/255.f alpha:1];
//        UIColor*blueO=[UIColor blueColor];
//        UIColor*blueN=[blueO colorWithAlphaComponent:0.4];
        //_sure2.backgroundColor=blueN;
        [_tView addSubview:_sure2];
        [_sure2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(2);  make.top.offset(7);
            make.bottom.offset(-7);  make.width.offset(88);
        }];
        //放弃按钮
        _giveUp2=[UIButton new];
        _giveUp2.titleLabel.font=lFont;
        [_giveUp2 setTitle:@"放弃" forState:UIControlStateNormal];
        [_giveUp2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _giveUp2.backgroundColor=[UIColor lightGrayColor];
        [_tView addSubview:_giveUp2];
        [_giveUp2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_sure2.mas_right).offset(20);
            make.top.offset(7);
            make.bottom.offset(-7);
            make.width.offset(88);
        }];
        
        //第三个view显示中标、查看订单
        _thView=[UIView new];
        [self addSubview:_thView];
//        [_thView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(40);
//            make.bottom.offset(-5);
//            make.right.offset(0);
//        }];
        //中标按钮
        _theWinning3=[UIButton new];
        _theWinning3.titleLabel.font=lFont;
        [_theWinning3 setTitle:@"中标" forState:UIControlStateNormal];
        [_theWinning3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        UIColor*redAlphO=[UIColor redColor];
        UIColor*redAlphN=[redAlphO colorWithAlphaComponent:0.8];
        _theWinning3.backgroundColor=redAlphN;
        [_thView addSubview:_theWinning3];
        [_theWinning3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(2);  make.top.offset(7);
            make.bottom.offset(-7);  make.width.offset(88);
        }];
        //查看订单按钮
        _check3=[UIButton new];
        _check3.titleLabel.font=lFont;
        [_check3 setTitle:@"订单详情" forState:UIControlStateNormal];
        [_check3 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [_thView addSubview:_check3];
        [_check3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_theWinning3.mas_right).offset(20);
            make.top.offset(7);
            make.bottom.offset(-7);
            make.width.offset(88);
        }];

        //第四个view
        _fView=[UIView new];
        [self addSubview:_fView];
//        [_fView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(40);
//            make.bottom.offset(-5);
//            make.right.offset(0);
//        }];
        //已放弃按钮
        _giveUpHave4=[UIButton new];
        _giveUpHave4.titleLabel.font=lFont;
        [_giveUpHave4 setTitle:@"已失效" forState:UIControlStateNormal];
        [_giveUpHave4 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _giveUpHave4.backgroundColor=[UIColor lightGrayColor];
        [_fView addSubview:_giveUpHave4];
        [_giveUpHave4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(2);  make.top.offset(7);
            make.bottom.offset(-7);  make.width.offset(88);
        }];
        
//        UIImageView*HlineImg=[[UIImageView alloc]init];
//        HlineImg.backgroundColor=[UIColor lightGrayColor];
//        [self addSubview:HlineImg];
//        [HlineImg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.offset(20);  make.right.offset(-2);
//            make.height.offset(0.4); make.bottom.offset(-0.4);
//        }];
        
        
        
    _suoHuo1.layer.masksToBounds=YES;
    _suoHuo1.layer.cornerRadius=13;
    _suoHuo1.layer.borderWidth=0.3;
    _suoHuo1.layer.borderColor=[UIColor lightGrayColor].CGColor;
    
    _xiaDan1.layer.masksToBounds=YES;
    _xiaDan1.layer.cornerRadius=13;
    _xiaDan1.layer.borderWidth=0.3;
    _xiaDan1.layer.borderColor=[UIColor lightGrayColor].CGColor;
    
    _sure2.layer.masksToBounds=YES;
    _sure2.layer.cornerRadius=13;
    _sure2.layer.borderWidth=0.3;
    _sure2.layer.borderColor=[UIColor lightGrayColor].CGColor;
    
    _giveUp2.layer.masksToBounds=YES;
    _giveUp2.layer.cornerRadius=13;
    _giveUp2.layer.borderWidth=0.3;
    _giveUp2.layer.borderColor=[UIColor lightGrayColor].CGColor;
        
    _theWinning3.layer.masksToBounds=YES;
    _theWinning3.layer.cornerRadius=13;
    _theWinning3.layer.borderWidth=0.3;
    _theWinning3.layer.borderColor=[UIColor lightGrayColor].CGColor;
        
    _check3.layer.masksToBounds=YES;
    _check3.layer.cornerRadius=13;
    _check3.layer.borderWidth=0.3;
    _check3.layer.borderColor=[UIColor lightGrayColor].CGColor;
        
    _giveUpHave4.layer.masksToBounds=YES;
    _giveUpHave4.layer.cornerRadius=13;
    _giveUpHave4.layer.borderWidth=0.3;
    _giveUpHave4.layer.borderColor=[UIColor lightGrayColor].CGColor;
        
        
        
        
    }
    return self;
    
}

- (void)awakeFromNib {
   
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
